package com.soriya.nestlive.controller.api;

import com.soriya.nestlive.entity.UserEntity;
import com.soriya.nestlive.entity.param.LoginParam;
import com.soriya.nestlive.entity.vo.InfoVo;
import com.soriya.nestlive.service.UserService;
import com.soriya.nestlive.util.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user")
public class UserApi {

    private final UserService userService;

    @Autowired
    public UserApi(UserService userService) {
        this.userService = userService;
    }

    @PostMapping("/login")
    public Result<?> login(@RequestBody LoginParam login) {
        String token = userService.login(login);
        return Result.success(token);
    }

    @GetMapping("/info")
    public Result<?> getInfo() {
        UserEntity info = userService.getInfo();
        return Result.success(info);
    }

}
